package org.hry.file.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class TransferFrom {
    public static void main(String[] args) throws IOException {
        Long start = System.currentTimeMillis();
        File source = new File("E:\\source.zip");
        File dest = new File("E:\\back.zip");
        try(FileChannel inChannel = new FileInputStream(source).getChannel(); FileChannel outChannel = new FileOutputStream(dest).getChannel()) {
            outChannel.transferFrom(inChannel, 0, inChannel.size());
        }
        System.out.println("总共耗时：" + (System.currentTimeMillis() - start));
    }
}
